<template>
  <div>
    <div class="title">
      <el-row>
        <el-col :span="1" style="width: 50px;">
          <span style="color:#757575;">位置 :</span>
        </el-col>
        <el-col :span="20">
          <span class="hand" @click="tableshow1" :class="{'textactive' : !secondshow}">{{title}}</span>
          <span v-if="secondshow" :class="{'textactive' : secondshow}"> > {{secondtitle}}</span>
        </el-col>
      </el-row>
    </div>
    <div class="posttable" v-show="!secondshow">
      <el-row type="flex" justify="center">
        <el-col :span="23">
          <div style="margin-bottom:20px;float: right;">
            <el-row type="flex" justify="space-between" style="margin-top: 11px;" class="btn">
              <el-input
                style="width: 136px;"
                size="small"
                placeholder="请输入内容"
                v-model.trim="inputValue"
                @keyup.enter.native="searchMsg"
              >
                <i
                  slot="suffix"
                  class="el-input__icon el-icon-search"
                  style="cursor: pointer;"
                  @click="searchMsg"
                ></i>
              </el-input>
              <div style="margin-left: 5px;">
                <el-button
                  class="edit"
                  @mousedown.native="editdown"
                  @mouseup.native="editup"
                  :class="{'active1' : newcolor1}"
                  size="small"
                  @click="editClick"
                  round
                  v-if="editBool"
                >修改
                </el-button>
                <el-button
                  class="send"
                  @mousedown.native="senddown"
                  @mouseup.native="sendup"
                  :class="{'active2' : newcolor2}"
                  size="small"
                  round
                  v-if="sendBool"
                  @click="sendClick"
                >发送
                </el-button>
                <el-button
                  class="toHR"
                  @mousedown.native="toHRdown"
                  @mouseup.native="toHRup"
                  v-if="jiaofu"
                  :class="{'active3' : newcolor3}"
                  size="small"
                  round
                  @click="toHRClick"
                >转HR
                </el-button>
              </div>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <el-row type="flex" justify="center">
        <el-col :span="23">
          <el-table
            ref="singleTable"
            highlight-current-row
            :data="tableData"
            @current-change="handleCurrentChange"
            class="tableT"
          >
            <el-table-column prop="customerName" label="客户名称"></el-table-column>
            <el-table-column prop="name" label="姓名"></el-table-column>
            <el-table-column prop="pusherName" v-if="recommend" label="推荐人"></el-table-column>
            <el-table-column prop="postName" label="入职职位"></el-table-column>
            <el-table-column prop="postLevel" label="职位级别"></el-table-column>
            <el-table-column prop="area" label="入职地区"></el-table-column>
            <el-table-column prop="education" label="学历"></el-table-column>
            <el-table-column prop="phone" label="联系电话"></el-table-column>
            <el-table-column prop="mail" label="邮箱"></el-table-column>
            <el-table-column label="身份证文件">
              <template slot-scope="scope">
                <span v-if="scope.row.identityPath !== null && scope.row.identityPath !== ''"><a class="other"
                                                                                                 :href="scope.row.identityPath"
                                                                                                 target="_blank">{{scope.row.identityFileName}}</a></span>
                <span v-else>{{scope.row.identity}}</span>
              </template>
            </el-table-column>
            <el-table-column label="毕业证文件">
              <template slot-scope="scope">
                <span v-if="scope.row.diplomaPath !== null && scope.row.diplomaPath !== ''"><a class="other"
                                                                                               :href="scope.row.diplomaPath"
                                                                                               target="_blank">{{scope.row.diplomaFileName}}</a></span>
                <span v-else>{{scope.row.diploma}}</span>
              </template>
            </el-table-column>
            <el-table-column label="学历证书文件">
              <template slot-scope="scope">
                <span v-if="scope.row.educationPath !== null && scope.row.educationPath !== ''"><a class="other"
                                                                                                   :href="scope.row.educationPath"
                                                                                                   target="_blank">{{scope.row.educationFilename}}</a></span>
                <span v-else>{{scope.row.educations}}</span>
              </template>
            </el-table-column>
            <el-table-column label="入职时间">
              <template slot-scope="scope">
                <span v-if="scope.row.realEntryScore == null">{{scope.row.entryTime}}</span>
                <span v-else>{{scope.row.entryTime + scope.row.realEntryScore}}</span>
              </template>
            </el-table-column>
            <el-table-column label="进场时间">
              <template slot-scope="scope">
                <span v-if="scope.row.realSceneScore == null">{{scope.row.sceneTime}}</span>
                <span v-else>{{scope.row.sceneTime + scope.row.realSceneScore}}</span>
              </template>
            </el-table-column>
          </el-table>
          <div class="pager">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="pagehandleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5,10,15]"
              :page-size="pagesize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalcount"
            ></el-pagination>
          </div>
        </el-col>
      </el-row>
      <el-dialog
        title="修改时间"
        :visible.sync="timeDialogVisible"
        width="415px"
        :before-close="timeClose"
        class="addP"
      >
        <el-form :model="time" ref="form" :rules="rule" label-position="top">
          <el-form-item label="入职时间" prop="entryTime">
            <el-date-picker
              width="100%"
              v-model="time.entryTime"
              type="date"
              value-format="yyyy-MM-dd"
              format="yyyy-MM-dd"
              placeholder="请选择入职时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item
            label="入职时间范围"
            prop="realEntryScore"
          >
            <el-col>
              <el-select v-model.trim="time.realEntryScore" placeholder="请选择时间范围" class="timeselect">
                <el-option
                  v-for="(item,index) in timelist"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="进场时间" prop="sceneTime">
            <el-date-picker
              width="100%"
              v-model="time.sceneTime"
              type="date"
              value-format="yyyy-MM-dd"
              format="yyyy-MM-dd"
              placeholder="请选择进场时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item
            label="进场时间范围"
            prop="realSceneScore"
          >
            <el-col>
              <el-select v-model.trim="time.realSceneScore" placeholder="请选择时间范围" class="timeselect">
                <el-option
                  v-for="(item,index) in timelist"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="身份证号" prop="idCard">
            <el-col>
              <el-input v-model.trim="time.idCard" placeholder="请输入身份证号"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="毕业证号" prop="idDiploma">
            <el-col>
              <el-input v-model.trim="time.idDiploma" placeholder="请输入毕业证号"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="学历证号" prop="idEducation">
            <el-col>
              <el-input v-model.trim="time.idEducation" placeholder="请输入学历证号"></el-input>
            </el-col>
          </el-form-item>
          <el-col>
            <el-form-item>
              <div style="max-width:32rem;margin-top: 10px;">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  type="file"
                  :action="actionurl"
                  :before-upload="beforeupload"
                  :show-file-list="true"
                  :file-list="fileList"
                  :on-success="handleAvatarSuccess"
                  :on-remove="handleRemove"
                  :limit="2"
                  accept=".pdf"
                >
                  <el-button class="upload" slot="trigger">选取身份证信息文件</el-button>
                </el-upload>
              </div>
            </el-form-item>
            <el-col style="margin-bottom: 10px;">
              <div
                v-if="!filetype"
                style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;"
              >文件上传格式为pdf。
              </div>
              <div
                v-if="selectfile"
                style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;"
              >请上传身份证信息文件!
              </div>
            </el-col>
          </el-col>
          
          <el-col>
            <el-form-item>
              <div style="max-width:32rem;">
                <el-upload
                  class="upload-demo"
                  ref="upload1"
                  type="file"
                  :action="actionurl1"
                  :before-upload="beforeupload1"
                  :show-file-list="true"
                  :file-list="fileList1"
                  :on-success="handleAvatarSuccess1"
                  :on-remove="handleRemove1"
                  :limit="2"
                  accept=".pdf"
                >
                  <el-button class="upload" slot="trigger">选取毕业证信息文件</el-button>
                </el-upload>
              </div>
            </el-form-item>
            <el-col style="margin-bottom: 10px;">
              <div
                v-if="!filetype1"
                style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;"
              >文件上传格式为pdf。
              </div>
              <div
                v-if="selectfile1"
                style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;"
              >请上传毕业证信息文件!
              </div>
            </el-col>
          </el-col>
          
          <el-col>
            <el-form-item>
              <div style="max-width:32rem;">
                <el-upload
                  class="upload-demo"
                  ref="upload2"
                  type="file"
                  :action="actionurl2"
                  :before-upload="beforeupload2"
                  :show-file-list="true"
                  :file-list="fileList2"
                  :on-success="handleAvatarSuccess2"
                  :on-remove="handleRemove2"
                  :limit="2"
                  accept=".pdf"
                >
                  <el-button class="upload" slot="trigger">选取学历证书息文件</el-button>
                </el-upload>
              </div>
            </el-form-item>
            <el-col style="margin-bottom: 10px;">
              <div
                v-if="!filetype2"
                style="color: #F56C6C;color: #F56C6C;font-size: 12px;line-height: 1;padding-top: 4px;"
              >文件上传格式为pdf。
              </div>
            </el-col>
          </el-col>
        
        </el-form>
        <span slot="footer" class="dialog-footer">
        <el-button class="sure" round @click="timeConfirm('form')">确 定</el-button>
        <el-button round @click="timeClose" class="cancel">取 消</el-button>
      </span>
      </el-dialog>
      <el-dialog
        title="错误"
        :visible.sync="editdialogVisible"
        width="30%"
        :before-close="handleClose"
        class="deletedialog"
      >
        <div style="text-align: center">
          <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
            <span style="font-size: 16px;color: #333;margin-left: 12px;">尚未选择任何数据</span>
          </i>
        </div>
        <span slot="footer" class="dialog-footer">
        <el-button class="sure" round @click="handleClose">确 定</el-button>
        <el-button round @click="handleClose" class="cancel">取 消</el-button>
      </span>
      </el-dialog>
      <el-dialog
        title="错误"
        :visible.sync="hrdialogVisible"
        width="30%"
        :before-close="handleHrClose"
        class="deletedialog"
      >
        <div style="text-align: center">
          <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
            <span style="font-size: 16px;color: #333;margin-left: 12px;">该客户需求外包人员不可转入HR系统</span>
          </i>
        </div>
        <span slot="footer" class="dialog-footer">
        <el-button class="sure" round @click="handleHrClose">确 定</el-button>
        <el-button round @click="handleHrClose" class="cancel">取 消</el-button>
      </span>
      </el-dialog>
      <el-dialog :visible.sync="dialogMailVisible" :before-close="cancelSend" class="back1">
        <div class="dialogBox">
          <el-row>
            <el-col :span="2" style="line-height:28px;color:#0e6195">收件人：</el-col>
            <el-col :span="10" class="receive">
              <el-input v-model="mail" style="width:200px;"></el-input>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="23">
              <div class="line"></div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="2" style="line-height:28px;color:#999798">主&nbsp;&nbsp;&nbsp;&nbsp;题：</el-col>
            <el-col :span="10" style="line-height:28px;font-size:12px;font-weight:700;">
              {{theme}}
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <span style="margin-right:10px;line-height:40px"><a :href="fileUrl" class="resumeLink" target="_blank">{{originalFilename}}</a></span>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="23">
              <div class="lightLine"></div>
            </el-col>
          </el-row>
          <el-row style="border: 1px solid #ccc;">
            <div style="margin-left:10px">
              <p>范总，您好：</p>
              <p>以下人员需驻场到<span style="font-weight:700;text-decoration: underline;">{{msg}}</span>,已通过面试可以联系员工发送入职要求，信息如下：
              </p>
              <p>简历见附件</p>
            </div>
            <el-col style="padding-left: 10px;" class="mailtable">
              <el-table
                class="tablelist"
                ref="mailtable"
                :data="maildata"
                border
              >
                <el-table-column
                  label="姓名"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.name"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="postName"
                  label="岗位名称"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.postName"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="postLevel"
                  label="级别"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.postLevel"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="education"
                  label="学历"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.education"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  
                  label="证书资质"
                >
                  <template slot-scope="scope">
                    <el-input v-model="certificate"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="phone"
                  label="联系电话"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.phone"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="mail"
                  label="邮箱"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.mail"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="薪资"
                >
                  <template slot-scope="scope">
                    <el-input v-model="salary"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="试用期"
                >
                  <template slot-scope="scope">
                    <el-input v-model="probation"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="福利权限"
                >
                  <template slot-scope="scope">
                    <el-input v-model="welfare"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="替换/新增"
                >
                  <template slot-scope="scope">
                    <el-input v-model="changeoradd"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="origin"
                  label="简历来源"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.origin"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="备注"
                >
                  <template slot-scope="scope">
                    <el-input v-model="remarks"></el-input>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <div style="margin-left:10px">
              <p>入职地点：
                <el-input v-model="entryCompany" style="width:100px"></el-input>
              </p>
              <p>入职时间：{{entryTime}} {{realEntryScore}}</p>
              <p>进场时间：{{sceneTime}} {{realSceneScore}}</p>
              <p>社保缴纳地：
                <el-input v-model="socialsecurity" style="width:100px"></el-input>
              </p>
              <p>入职流程：<span style="color:#f40">走正常流程，体检报告合格后发放offer</span></p>
            </div>
            <el-col style="text-indent: 1.5em;margin-top: 30px;margin-left: 10px;margin-bottom: 30px;">
              <p>软件研发中心 {{this.userInfo.name}}</p>
              <p><span>南通东华软件有限公司</span></p>
              <p><span>地址 : </span><span>海安市城东镇天发路9号海晟慧谷科创服务中心2号楼第8层</span></p>
              <p><span>邮编 : </span><span>226600</span></p>
              <p><span>电话 : </span><span>0513 - 88805918</span></p>
              <p><span>传真 : </span><span>0513 - 88805938</span></p>
              <p><span>手机 : </span><span>{{this.userInfo.phone}}</span></p>
              <p><span>网址 : </span><span>www.ntdhcc.com</span></p>
              <p><span>邮箱 : </span><span>{{this.userInfo.email}}</span></p>
            </el-col>
            
            <el-col style="margin-bottom: 18px;">
              <el-row type="flex" justify="center">
                <el-col :span="23">
                  <div class="lightLine"></div>
                </el-col>
              </el-row>
            
            </el-col>
            
            <el-col>
            </el-col>
          </el-row>
        </div>
        <div slot="title" class="dialog-title">
          <el-button type="primary" @click="sendEmail" :disabled="!sendEmailKey" style="font-size:16px;">
            <i class="iconfont icon-plane"></i>
            <span style="margin-left:6px;"> 发送</span>
          </el-button>
          <el-button @click="cancelSend">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <to-hr v-if="secondshow" :resumeId="resumeId" @getData="getData"></to-hr>
  </div>
</template>
<script>
  import axios from 'axios'
  import ToHr from './toHr'
  
  import tagsView from '../../store/modules/tagsView'
  
  export default {
    data() {
      return {
        title: "入职申请",
        secondtitle: "",
        inputValue: "",
        copyMail: "",
        newcolor1: false,
        newcolor2: false,
        newcolor3: false,
        recommend: false,
        mail: "fandp@ntdhcc.com",
        maildata: [],
        tableData: [],
        fileUrl: "",
        resumeId: "",
        jiaofu: true,
        secondshow: false,
        currentRow: null,
        theme: "",
        msg: "",
        certificate: "",
        salary: "",
        probation: "",
        changeoradd: "",
        remarks: "",
        welfare: "",
        socialsecurity: "",
        entryCompany: "",
        originalFilename: "",
        entryTime: "",
        realEntryScore: "",
        sceneTime: "",
        realSceneScore: "",
        userInfo: "",
        currentPage: 1,
        pagesize: 15,
        totalcount: 0,
        sendEmailKey: true,
        timeDialogVisible: false,
        editdialogVisible: false,
        dialogMailVisible: false,
        hrdialogVisible: false,
        editBool: false,
        sendBool: false,
        time: {
          entryTime: null,
          sceneTime: null,
          realEntryScore: '',
          realSceneScore: '',
          idCard: '',
          idDiploma: '',
          idEducation: '',
        },
        timelist: ['上午', '下午'],
        rule: {
          entryTime: [
            {required: true, message: "请输入入职时间", trigger: "blur"}
          ],
          sceneTime: [
            {required: true, message: "请输入进场时间", trigger: "blur"}
          ],
          realEntryScore: [
            {required: true, message: '请选择入职时间范围', trigger: 'change'}
          ],
          realSceneScore: [
            {required: true, message: '请选择进场时间范围', trigger: 'change'}
          ],
          idCard: [
            {required: true, message: "请输入身份证号", trigger: "blur"},
            {
              pattern:
                /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/,
              message: "请输入正确的身份证号",
              trigger: "blur"
            }
          ],
          idDiploma: [
            {required: true, message: "请输入毕业证号", trigger: "blur"},
            {max: 20, message: '长度在20个字符之内', trigger: 'blur'}
          ],
          idEducation: [
            {required: true, message: "请输入学历证号", trigger: "blur"},
            {max: 20, message: '长度在20个字符之内', trigger: 'blur'}
          ]
        },
        actionurl: null,
        actionurl1: null,
        actionurl2: null,
        fileList: [],
        file: {},
        filetype: true,
        selectfile: false,
        fileList1: [],
        file1: {},
        filetype1: true,
        selectfile1: false,
        fileList2: [],
        file2: {},
        filetype2: true
      }
    },
    created() {
      //身份证身份证文件接口地址
      this.actionurl = this.url + "/statistics/entryInfo/identityUpload";
      //毕业证文件接口地址
      this.actionurl1 = this.url + "/statistics/entryInfo/diplomaUpload";
      //学历证书接口
      this.actionurl2 = this.url + "/statistics/entryInfo/educationUpload";
      if (tagsView.state.identity == 7) {
        this.jiaofu = false;
      }
      this.getData();
      axios.post(this.url + "/auth/getModularByMenu", {
        menuId: 23
      }).then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          if (res.data.data.length > 0) {
            for (let i = 0, len = res.data.data.length; i < len; i++) {
              if (res.data.data[i].modularId == "233") {
                this.editBool = true    // 修改按钮显示
              } else if (res.data.data[i].modularId == "234") {
                this.sendBool = true    // 发送按钮显示
              }
            }
          }
        }
      });
      axios.post(this.url + "/auth/getDataByMenu", {
        menuId: 23
      }).then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          if (res.data.data.length > 0) {
            this.recommend = true;
          }
        }
      })
    },
    methods: {
      toHRClick() {
        if (this.currentRow) {
          axios.post(this.url + "/entry/apply/getHRS", {
            customerName: this.currentRow.customerName
          }).then(res => {
            this.unlogin(res.data.code)
            if (res.data.code == 200 && res.data.data == 'true') {
              this.resumeId = this.currentRow.resumeId;
              this.secondshow = true;
              this.secondtitle = "转HR";
            } else {
              this.hrdialogVisible = true;
              document.documentElement.style.overflow = "hidden";
            }
          })
          
        } else {
          this.resumeId = '';
          this.secondshow = true;
          this.secondtitle = "转HR";
        }
        
      },
      tableshow() {
        this.secondshow = false;
        this.secondtitle = "";
      },
      tableshow1(row) {
        this.secondshow = false;
        this.secondtitle = "";
        this.$refs.singleTable.setCurrentRow(row);
        this.currentRow = null;
      },
      getData() {
        this.tableshow();
        axios.post(this.url + "/entry/apply/getApplyList", {
          condition: this.inputValue,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.tableData = res.data.data.list;
            this.totalcount = res.data.data.total;
          }
        })
      },
      searchMsg() {
        this.currentPage = 1;
        axios.post(this.url + "/entry/apply/getApplyList", {
          condition: this.inputValue,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.tableData = res.data.data.list;
            this.totalcount = res.data.data.total;
          }
        })
      },
      editdown() {
        this.newcolor1 = true;
      },
      editup() {
        this.newcolor1 = false;
      },
      senddown() {
        this.newcolor2 = true;
      },
      sendup() {
        this.newcolor2 = false;
      },
      toHRdown() {
        this.newcolor3 = true;
      },
      toHRup() {
        this.newcolor3 = false;
      },
      handleCurrentChange(val) {
        this.currentRow = val;
      },
      handleSizeChange(val) {
        this.pagesize = val;
        this.getData();
      },
      pagehandleCurrentChange(val) {
        this.currentPage = val;
        this.getData();
      },
      handleHrClose() {
        this.hrdialogVisible = false;
        document.documentElement.style.overflow = "auto";
        this.$refs.singleTable.setCurrentRow();
      },
      // 修改按钮点击
      editClick() {
        if (this.currentRow) {
          axios.post(this.url + '/entry/apply/getDetailById', {
            id: this.currentRow.id
          }).then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              this.time = res.data.data;
            }
          })
          if (typeof this.currentRow.identityFileName !== "undefined" && this.currentRow.identityFileName !== null && this.currentRow.identityFileName !== "") {
            this.fileList = [];
            this.fileList.push({name: this.currentRow.identityFileName})
            this.file = {name: this.currentRow.identityFileName}
          } else {
            this.fileList = [];
            this.file = {};
          }
          
          if (typeof this.currentRow.diplomaFileName !== "undefined" && this.currentRow.diplomaFileName !== null && this.currentRow.diplomaFileName !== "") {
            this.fileList1 = [];
            this.fileList1.push({name: this.currentRow.diplomaFileName})
            this.file1 = {name: this.currentRow.diplomaFileName}
          } else {
            this.fileList1 = [];
            this.file1 = {};
          }
          
          if (typeof this.currentRow.educationFilename !== "undefined" && this.currentRow.educationFilename !== null && this.currentRow.educationFilename !== "") {
            this.fileList2 = [];
            this.fileList2.push({name: this.currentRow.educationFilename})
            this.file2 = {name: this.currentRow.educationFilename}
          } else {
            this.fileList2 = [];
            this.file2 = {};
          }
          
          this.$nextTick(() => {
            this.$refs.form.clearValidate();
          });
          this.timeDialogVisible = true;
          document.documentElement.style.overflow = "hidden";
        } else {
          this.editdialogVisible = true;
          document.documentElement.style.overflow = "hidden";
        }
      },
      // 发送按钮点击
      sendClick() {
        if (this.currentRow) {
          axios.post(this.url + "/entry/apply/getHRS", {
            customerName: this.currentRow.customerName
          }).then(res => {
            this.unlogin(res.data.code)
            if (res.data.code == 200 && res.data.data == 'false') {
              this.maildata = [];
              if (this.currentRow) {
                this.dialogMailVisible = true;
                document.documentElement.style.overflow = "hidden";
                axios.post(this.url + "/entry/apply/getMailDetail", {
                  id: this.currentRow.id
                }).then(res => {
                  this.unlogin(res.data.code)
                  if (res.data.code == 200) {
                    this.maildata.push(res.data.data.mailDetail)
                    this.userInfo = res.data.data.userInfo
                    this.theme = this.maildata[0].customerName + "外包人员" + " " + this.maildata[0].name + " " + "入职申请";
                    this.msg = this.maildata[0].area + this.maildata[0].customerName
                    this.socialsecurity = this.maildata[0].area
                    this.entryCompany = this.maildata[0].area + "公司"
                    this.entryTime = this.maildata[0].entryTime
                    this.sceneTime = this.maildata[0].sceneTime
                    this.realEntryScore = this.maildata[0].realEntryScore
                    this.realSceneScore = this.maildata[0].realSceneScore
                    this.originalFilename = this.maildata[0].originalFilename
                    this.fileUrl = "/" + this.maildata[0].group + "/" + this.maildata[0].fileAddress
                    this.maildata[0].certificate = "";
                    this.maildata[0].salary = "";
                    this.maildata[0].changeoradd = "";
                    this.maildata[0].remarks = "";
                    this.maildata[0].welfare = ""
                  }
                })
              } else {
                this.editdialogVisible = true;
                document.documentElement.style.overflow = "hidden";
              }
            } else {
              this.$message({
                showClose: true,
                message: '该客户需求外包人员不可发送邮件',
                type: 'warning'
              })
            }
          })
        } else {
          this.editdialogVisible = true;
          document.documentElement.style.overflow = "hidden";
        }
      },
      // 修改时间确定
      timeConfirm(formName) {
        
        if (this.file.name == undefined) {
          this.selectfile = true;
        } else {
          this.selectfile = false;
        }
        
        if (this.file1.name == undefined) {
          this.selectfile1 = true;
        } else {
          this.selectfile1 = false;
        }
        
        this.$refs[formName].validate(valid => {
          if (valid && !this.selectfile && this.filetype && this.filetype1 && !this.selectfile1) {
            axios.post(this.url + "/entry/apply/updateTime", {
              id: this.currentRow.id,
              entryTime: this.time.entryTime,
              sceneTime: this.time.sceneTime,
              realEntryScore: this.time.realEntryScore,
              realSceneScore: this.time.realSceneScore,
              idCard: this.time.idCard,
              idDiploma: this.time.idDiploma,
              idEducation: this.time.idEducation,
              identityPath: this.time.identityPath,
              identityGroup: this.time.identityGroup,
              identityFileName: this.time.identityFileName,
              identityFileAddress: this.time.identityFileAddress,
              identitySuffix: this.time.identitySuffix,
              diplomaPath: this.time.diplomaPath,
              diplomaGroup: this.time.diplomaGroup,
              diplomaFileName: this.time.diplomaFileName,
              diplomaFileAddress: this.time.diplomaFileAddress,
              diplomaSuffix: this.time.diplomaSuffix,
              educationPath: this.time.educationPath,
              educationGroup: this.time.educationGroup,
              educationFilename: this.time.educationFilename,
              educationAddress: this.time.educationAddress,
              educationSuffix: this.time.educationSuffix
            })
              .then(res => {
                this.unlogin(res.data.code)
                if (res.data.code == 200) {
                  this.getData();
                  this.$refs.singleTable.setCurrentRow();
                  this.timeDialogVisible = false;
                  document.documentElement.style.overflow = "auto"
                }
              })
          }
        })
      },
      // 取消修改
      timeClose() {
        this.timeDialogVisible = false;
        document.documentElement.style.overflow = "auto";
        this.$refs.singleTable.setCurrentRow();
        this.$refs.form.resetFields();
        this.selectfile = false;
        this.selectfile1 = false;
        this.filetype = true;
        this.filetype1 = true;
        this.filetype2 = true;
        this.file = {};
        this.fileList = [];
        this.file1 = {};
        this.fileList1 = [];
        this.file2 = {};
        this.fileList2 = [];
      },
      handleClose() {
        this.editdialogVisible = false;
        document.documentElement.style.overflow = "auto";
      },
      // 取消发送邮件
      cancelSend() {
        this.dialogMailVisible = false;
        document.documentElement.style.overflow = "auto";
        this.$refs.singleTable.setCurrentRow();
      },
      sendEmail() {
        this.sendEmailKey = false;
        axios.post(this.url + "/entry/apply/sendMail", {
          subject: this.theme,
          to: this.mail,
          id: this.currentRow.id,
          resumeId: this.currentRow.resumeId,
          name: this.maildata[0].name,
          postName: this.maildata[0].postName,
          postLevel: this.maildata[0].postLevel,
          education: this.maildata[0].education,
          certificate: this.certificate,
          phone: this.maildata[0].phone,
          mail: this.maildata[0].mail,
          salary: this.salary,
          welfare: this.welfare,
          changeoradd: this.changeoradd,
          probation: this.probation,
          origin: this.maildata[0].origin,
          remarks: this.remarks,
          entryCompany: this.entryCompany,
          socialsecurity: this.socialsecurity,
          msg: this.msg,
          entryTime: this.entryTime,
          realEntryScore: this.realEntryScore,
          realSceneScore: this.realSceneScore,
          sceneTime: this.sceneTime
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.sendEmailKey = true;
            this.dialogMailVisible = false;
            document.documentElement.style.overflow = "auto"
            this.$refs.singleTable.setCurrentRow();
            this.certificate = "";
            this.salary = "";
            this.changeoradd = "";
            this.remarks = "";
            this.welfare = "";
            this.socialsecurity = "";
            this.entryCompany = "";
          }
        })
      },
      // 上传身份证信息的文件
      beforeupload(file) {
        this.file = {};
        this.file = file;
        this.selectfile = false;
        var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
        this.filetype = testmsg == "pdf";
        
        if (this.filetype) {
          this.file = file;
          this.fileList = [];
          this.fileList.push(this.file);
        }
        
        return this.filetype;
      },
      handleRemove(file, fileList) {
        this.file = {};
        this.fileList = [];
        this.time.identityPath = '';
        this.time.identityGroup = '';
        this.time.identityFileName = '';
        this.time.identityFileAddress = '';
        this.time.identitySuffix = '';
      },
      handleAvatarSuccess(res, file) {
        this.time.identityPath = res.data.identityPath;
        this.time.identityGroup = res.data.identityGroup;
        this.time.identityFileName = res.data.identityFileName;
        this.time.identityFileAddress = res.data.identityFileAddress;
        this.time.identitySuffix = res.data.identitySuffix;
      },
      // 上传毕业证信息的文件
      beforeupload1(file) {
        this.file1 = {};
        this.file1 = file;
        this.selectfile1 = false;
        var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
        this.filetype1 = testmsg == "pdf";
        if (this.filetype1) {
          this.file1 = file;
          this.fileList1 = [];
          this.fileList1.push(this.file1);
        }
        return this.filetype1;
      },
      handleRemove1(file, fileList) {
        this.fileList1 = [];
        this.file1 = {};
        this.time.diplomaPath = '';
        this.time.diplomaGroup = '';
        this.time.diplomaFileName = '';
        this.time.diplomaFileAddress = '';
        this.time.diplomaSuffix = '';
      },
      handleAvatarSuccess1(res, file) {
        this.time.diplomaPath = res.data.diplomaPath;
        this.time.diplomaGroup = res.data.diplomaGroup;
        this.time.diplomaFileName = res.data.diplomaFileName;
        this.time.diplomaFileAddress = res.data.diplomaFileAddress;
        this.time.diplomaSuffix = res.data.diplomaSuffix;
      },
      // 上传学位证信息的文件
      beforeupload2(file) {
        this.file2 = {};
        this.file2 = file;
        var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
        this.filetype2 = testmsg == "pdf";
        if (this.filetype2) {
          this.file2 = file;
          this.fileList2 = [];
          this.fileList2.push(this.file2);
        }
        return this.filetype2;
      },
      handleRemove2(file, fileList) {
        this.fileList2 = [];
        this.file2 = {};
        this.time.educationPath = '';
        this.time.educationGroup = '';
        this.time.educationFilename = '';
        this.time.educationAddress = '';
        this.time.educationSuffix = '';
      },
      handleAvatarSuccess2(res, file) {
        this.time.educationPath = res.data.educationPath;
        this.time.educationGroup = res.data.educationGroup;
        this.time.educationFilename = res.data.educationFilename;
        this.time.educationAddress = res.data.educationAddress;
        this.time.educationSuffix = res.data.educationSuffix;
      }
    },
    watch: {
      "inputValue": function (val) {
        if (val == "") {
          this.currentPage = 1;
          this.getData();
        }
      },
      // "currentRow": function (val) {
      //   if (val) {
      //     this.time.entryTime = val.entryTime;
      //     this.time.sceneTime = val.sceneTime
      //   }
      // }
    },
    components: {
      ToHr
    }
  }
</script>
<style scoped>
  .title {
    background-color: #fff;
    height: 40px;
    line-height: 40px;
    font-size: 14px;
    padding-left: 20px;
    margin-top: 6px;
    margin-bottom: 6px;
  }
  
  .posttable {
    min-height: 700px;
    background-color: #fff;
  }
  
  .textactive {
    color: #1099ff;
  }
  
  .tabletitle {
    margin-left: 20px;
    height: 50px;
    line-height: 50px;
  }
  
  .edit {
    width: 65px;
    height: 28px;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #5696f8 0%, #143dea 100%);
    padding: 7px 15px !important;
  }
  
  .edit:hover {
    color: #fff !important;
  }
  
  .send {
    width: 65px;
    height: 28px;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #ffbc1c 0%, #f69710 100%);
    padding: 7px 15px !important;
  }
  
  .send:hover {
    color: #fff !important;
  }
  
  .toHR {
    width: 65px;
    height: 28px;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #fc2342 0%, #d51934 100%);
    padding: 7px 15px !important;
  }
  
  .toHR:hover {
    color: #fff !important;
  }
  
  .active1 {
    background: linear-gradient(to bottom, #595dff 0%, #7073ff 100%);
  }
  
  .active2 {
    background: linear-gradient(to bottom, #ff9600 0%, #d68300 100%);
  }
  
  .active3 {
    background: linear-gradient(to bottom, #fa4863 0%, #d84359 100%);
  }
  
  .pager {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  
  .el-pagination {
    margin-left: 50%;
    transform: translateX(-50%);
  }
  
  .line {
    height: 1px;
    background-color: #c8c8c8;
    margin-top: 3px;
    margin-bottom: 20px;
  }
  
  .darkline {
    height: 1px;
    background-color: #4288c3;
    margin-top: 10px;
    margin-bottom: 20px;
    
  }
  
  .lightLine {
    height: 1px;
    background-color: #cccccc;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  
  .upload {
    width: 194px !important;
    height: 44px !important;
    margin-top: 10px;
    /* margin-bottom: 30px; */
  }
  
  .other {
    color: #1198ff;
    cursor: pointer;
    text-decoration: none;
  }
</style>
